package com.Eastiy.EXO.Menu;

import android.content.Context;
import android.graphics.Color;
import android.graphics.LinearGradient;
import android.graphics.Shader;
import android.text.TextPaint;
import android.view.MotionEvent;
import android.view.View;
import android.widget.LinearLayout;
import android.widget.PopupWindow;
import android.widget.Toast;
import com.Eastiy.EXO.View.NewCDV;
import com.Eastiy.EXO.View.NewText;
import com.Eastiy.EXO.View.NewView;

public class FloatWin {
    /* access modifiers changed from: private */

    /* renamed from: X */
    public float f8X;
    /* access modifiers changed from: private */

    /* renamed from: Y */
    public float f9Y;
    /* access modifiers changed from: private */
    public boolean canmovePop = false;
    private Context context;
    public PopupWindow fwcdv;
    private NewView fwl;
    private NewText fwlt;
    private LinearLayout line;

    public FloatWin(Context context2) {
        this.context = context2;
        this.fwl = new NewView(context2, new Integer((int) (((double) m6H()) * 0.1d)), new Integer((int) (((double) m6H()) * 0.1d)), "CC", new Integer(1), 1, "#000000", new Integer(360), (View.OnClickListener) null);
        this.fwlt = new NewText(context2, "E", "CC", 25, "#000000");
        int measuredWidth = this.fwlt.getMeasuredWidth();
        TextPaint paint = this.fwlt.getPaint();
        int parseColor = Color.parseColor("#ffffff");
        int parseColor2 = Color.parseColor("#00FF00");
        int[] iArr = {parseColor, parseColor2};
        paint.setShader(new LinearGradient((float) 0, (float) 0, (float) measuredWidth, (float) 0, iArr, (float[]) null, Shader.TileMode.CLAMP));
        this.fwl.addView(this.fwlt);
        this.fwcdv = new NewCDV(this.fwl, new Integer((int) (((double) m6H()) * 0.1d)), new Integer((int) (((double) m6H()) * 0.1d)), false, true, true, "LT", (Object) null, (int) (((double) m7W()) * 0.02d), (int) (((double) m6H()) * 0.02d));
        this.fwl.setOnLongClickListener(new View.OnLongClickListener(this) {
            private final FloatWin this$0;

            {
                this.this$0 = r1;
            }

            static FloatWin access$0(AnonymousClass100000000 r1) {
                return r1.this$0;
            }

            @Override
            public boolean onLongClick(View view) {
                this.this$0.canmovePop = true;
                return false;
            }
        });
        this.fwl.setOnTouchListener(new View.OnTouchListener(this) {
            private float lastX;
            private float lastY;
            private float nowX;
            private float nowY;
            private final FloatWin this$0;
            private float tranX;
            private float tranY;

            {
                this.this$0 = r1;
            }

            static FloatWin access$0(AnonymousClass100000001 r1) {
                return r1.this$0;
            }

            @Override
            public boolean onTouch(View view, MotionEvent motionEvent) {
                int action = motionEvent.getAction();
                if (action == 0) {
                    this.lastX = motionEvent.getRawX();
                    this.lastY = motionEvent.getRawY();
                } else if (action == 1) {
                    if (!this.this$0.canmovePop) {
                        this.this$0.Onclick();
                    }
                    this.this$0.canmovePop = false;
                } else if (action == 2 && this.this$0.canmovePop) {
                    this.nowX = motionEvent.getRawX();
                    this.nowY = motionEvent.getRawY();
                    this.tranX = this.nowX - this.lastX;
                    this.tranY = this.nowY - this.lastY;
                    FloatWin floatWin = this.this$0;
                    floatWin.f8X = floatWin.f8X + this.tranX;
                    FloatWin floatWin2 = this.this$0;
                    floatWin2.f9Y = floatWin2.f9Y + this.tranY;
                    this.this$0.fwcdv.update(Math.round(this.this$0.f8X), Math.round(this.this$0.f9Y), -1, -1);
                    this.lastX = this.nowX;
                    this.lastY = this.nowY;
                }
                return false;
            }
        });
    }

    /* renamed from: H */
    private int m6H() {
        return this.context.getResources().getDisplayMetrics().heightPixels;
    }

    /* renamed from: W */
    private int m7W() {
        return this.context.getResources().getDisplayMetrics().widthPixels;
    }

    /* access modifiers changed from: package-private */
    public void Onclick() {
        GUIMain.show(this.context);
        dis();
    }

    public void dis() {
        this.fwcdv.dismiss();
    }

    public void show() {
        this.fwcdv.showAtLocation(this.fwl, 17, Math.round(this.f8X), Math.round(this.f9Y));
    }

    /* access modifiers changed from: package-private */
    public void show(String str) {
        Toast.makeText(this.context, str, 1).show();
    }
}
